home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
filmov.arc
/
FILMOV.PAS
Wrap
Pascal/Delphi Source File
|
1986-02-03
|
5KB
|
100 lines
(* ======================================================================== *)
(* A L T E R N A T I V E S T O "M O V E" A N D "F I L L C H A R" *)
(* *)
(* The routines in this file supplement the MOVE and FILLCHAR standard *)
(* procedures. Here is a chart of comparative timings. Times are in *)
(* seconds for 100 repetitions of an operation on 4000 bytes. *)
(* *)
(* MEMORY to MEMORY to SCREEN *)
(* ============================ *)
(* MOVEITER: 39 39 MOVE iteratively -- one byte after another *)
(* FILLITER: 28 28 FILL iteratively -- one byte after another *)
(* MOVE : 1.53 1.98 Built-in to TURBO *)
(* FILLCHAR: 0.88 1.37 Built-in to TURBO *)
(* MOVEWORD: 1.16 1.65 MOVE a whole word (2 bytes) at a time *)
(* FILLWORD: 0.60 1.15 FILL a whole word (2 bytes) at a time *)
(* MOVEOTHR: 2.80 3.08 MOVE every other byte *)
(* FILLOTHR: 2.20 2.30 FILL every other byte *)
(* *)
(* Note that if the total number of bytes is EVEN, MOVEWORD and FILLWORD *)
(* can be used to some speed advantage. Also, they are handy for video *)
(* memory, since each character/attribute pair takes one word. *)
(* MOVEITER and FILLITER are just included for comparison -- there's *)
(* no point in _using_ them! *)
(* MOVEOTHR and FILLOTHR act on every other byte. Again, these are *)
(* handy for video memory. How about rapidly FILLing a new attribute but *)
(* leaving all the characters the same? *)
(* *)
(* MOVEWORD and FILLWORD originated in messages on BIX, the Byte Info *)
(* eXchange, run by Byte magazine. *)
(* ======================================================================== *)
procedure MoveIter(VAR Source, Dest; Count : integer);
VAR
N : integer;
BEGIN
FOR N := 0 to Count-1 DO
MEM[Seg(Dest):Ofs(Dest)+N] := Mem[Seg(Source):Ofs(Source)+N];
END;
procedure FillIter(VAR Dest; Count : integer; FillVal : byte);
VAR
N : integer;
BEGIN
FOR N := 0 to Count-1 DO
MEM[Seg(Dest):Ofs(Dest)+N] := FillVal;
END;
Procedure FillWord ( VAR Dest; Count,FilVal : integer);
Begin Inline(
$1E/ {push DS }
$C4/$BE/Dest/ {les di,memr[bp] }
$8B/$46/<FilVal/ {mov ax,FilVal[bp] }
$8B/$4E/<count/ {mov cx,count[bp] }
$FC/ {cld ;forward dir }
$F3/$AB/ {rep stosw }
$1F); {pop ds }
End;
Procedure MoveWord(VAR Source,Dest;Count:integer);
Begin Inline($1E/ {push DS }
$C4/$7E/<dest/ {les di,dest[bp] }
$C5/$76/<source/ {lds si,source[bp] }
$8B/$4E/<count/ {mov cx,count[bp] }
$FC/ {cld }
$F3/$A5/ {rep movsw }
$1F); {pop ds }
end;
Procedure FillOthr ( VAR Dest; Count : integer; FilVal : byte);
Begin Inline(
$1E/ {push DS }
$C4/$BE/Dest/ {les di,memr[bp] }
$8A/$66/<FilVal/ {mov ah,FilVal[bp] }
$8B/$4E/<count/ {mov cx,count[bp] }
$31/$DB/ {XOR BX,BX }
{loupe} $26/ {SEG ES }
$88/$21/ {MOV [BX+DI],AH }
$43/ {INC BX }
$43/ {INC BX }
$E2/$F9/ {LOOP looop }
$1F); {pop ds }
End;
Procedure MoveOthr(VAR Source,Dest;Count:integer);
Begin Inline($1E/ {push DS }
$C4/$7E/<dest/ {les di,dest[bp] }
$C5/$76/<source/ {lds si,source[bp] }
$8B/$4E/<count/ {mov cx,count[bp] }
$31/$DB/ {XOR BX,BX }
{looop}
$8A/$20/ {MOV AH,[BX+SI] }
$26/ {SEG ES }
$88/$21/ {MOV [BX+DI],AH }
$43/ {INC BX }
$43/ {INC BX }
$E2/$F7/ {LOOP looop }
$1F); {pop ds }
end;